/*
 * Globales.c
 *
 *  Created on: 23/05/2011
 *      Author: Diego
 */
#include "Globales.h"
#include "FreeRTOS.h"
#include <queue.h>
#include "Colas.h"
#include "FreeRTOSConfig.h"
#include <task.h>

char readStatus(void) {
	char stat;
	taskENTER_CRITICAL();
	xQueueReceive(colaStatus, &stat, portMAX_DELAY);
	xQueueSend(colaStatus, &stat, portMAX_DELAY);
	taskEXIT_CRITICAL();
	return stat;
}
char readZonaActual(void) {
	char zone;
	xQueueReceive(colaZonaActual, &zone, portMAX_DELAY);
	xQueueSend(colaZonaActual, &zone, portMAX_DELAY);
	return zone;
}
int readSecuencia(void) {
	int seq;
	xQueueReceive(colaSecuencia, &seq, portMAX_DELAY);
	xQueueSend(colaSecuencia, &seq, portMAX_DELAY);
	return seq;
}

void writeStatus(char stat) {
	char tmp;
	xQueueReceive(colaStatus, &tmp, portMAX_DELAY);
	xQueueSend(colaStatus, &stat, portMAX_DELAY);
}
void writeZonaActual(char zone) {
	char tmp;
	xQueueReceive(colaZonaActual, &tmp, portMAX_DELAY);
	xQueueSend(colaZonaActual, &zone, portMAX_DELAY);
}
void writeSecuencia(int seq) {
	int tmp;
	xQueueReceive(colaSecuencia, &tmp, portMAX_DELAY);
	xQueueSend(colaSecuencia, &seq, portMAX_DELAY);
}
